Skip to content

Fix agent task workspace change normalization - #1790

Merged
chubes4 merged 3 commits into
mainfrom
fix/external-workspace-seed-snapshot
Jul 14, 2026
Merged

Fix agent task workspace change normalization#1790
chubes4 merged 3 commits into
mainfrom
fix/external-workspace-seed-snapshot

Conversation

@chubes4

@chubes4 chubes4 commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1788

Summary

  • seed runner workspaces from a filtered external snapshot, avoiding recursive workspace/artifact mounts
  • treat validated changed-files and patch evidence as actionable generic execution output without fabricating typed or package artifacts
  • emit repository-relative canonical patch headers so the host workspace patch applies safely
  • add real CLI Playground E2E coverage for workspace application, publication, refs, exclusions, and privacy
  • centralize cleanup of the private runtime source root and the runner workspace seed snapshot into one idempotent coordinator that every normal, failure, and finally path routes through exactly once; SIGINT/SIGTERM/SIGHUP await the same coordinator before exiting with the conventional 128+signum code, with a bounded synchronous best-effort fallback on process exit

Cleanup coordinator (final blocker)

  • Source relationship: replaces the four previously independent cleanup sites in .github/scripts/run-agent-task/execute-native-agent-task.mjs (mid-run awaits, an inline catch-path duplicate, a partial exit hook covering only the runtime source root, and signal handlers that cleaned only one resource and exited 128 for every signal).
  • Change kind: refactor of existing cleanup behavior plus a signal-handling correctness fix; no new runtime capability. The runtime change is not broader than the evidence: the same two temp roots are removed, only ownership moves to one coordinator and signal exits gain conventional codes.
  • Verification capability: tests/execute-native-agent-task-interruption.test.mjs deterministically starts the executor in a child process, pauses it immediately after seed snapshot creation via a narrowly scoped NODE_ENV=test marker-file hook (inert in production), delivers SIGTERM/SIGINT/SIGHUP, and asserts the temp seed snapshot directory is removed, the exit code is 143/130/129 respectively, and no runner workspace content survives; a normal run in the same harness proves routine cleanup still passes. tests/runtime-sources-materialization.test.ts pins the coordinator shape: one coordinator definition, signal handlers routed through it, a single top-level finally, and no duplicate independent cleanup logic. Error reporting/redaction is preserved (stderr failure messages are now redacted while the private root is still known).

How to test

  1. Run npm run build.
  2. Run npm run test:agent-task-contracts.
  3. Run npm run test:native-agent-task-playground-e2e.
  4. Run npm run test:native-agent-task-interruption and confirm it reports native agent task interruption ok after exercising SIGTERM, SIGINT, and SIGHUP plus a normal completion.
  5. Confirm the E2E reports native agent task Playground e2e ok; it verifies host README.md application, publication projection, canonical refs, empty typed artifacts, prepared workspace mounts, snapshot exclusions, and redaction.

Backwards compatibility

  • Agent task results with no validated file changes remain incomplete/no-op as before. Valid changed-file and patch evidence now allows an otherwise empty semantic workload to succeed.
  • Signal-interrupted executor runs now exit with the conventional 128+signum code (130/143/129) instead of a uniform 128. Only consumers matching the exact previous exit code 128 for signal deaths would observe the difference; the repository's own workflow treats any non-zero exit as failure.

AI assistance

  • AI assistance: Yes
  • Tool(s): openai/gpt-5.6-terra and OpenCode; Claude Opus 4.5 via OpenCode for the cleanup coordinator, signal handling, and interruption test
  • Used for: Implemented and verified the workspace snapshot, normalization, Playground E2E changes, and the centralized signal-safe cleanup with Chris-directed requirements.

chubes4 added 3 commits July 14, 2026 08:35
The executor previously carried four independent cleanup sites for the
private runtime source root and the runner workspace seed snapshot:
mid-run awaits, an inline catch-path duplicate, a partial exit hook, and
signal handlers that cleaned only one of the two resources and exited
128 for every signal.

Replace them with a single idempotent module-level coordinator that
claims both roots exactly once and chains repeat invocations onto the
in-flight cleanup instead of racing it. The top-level normal and
failure paths route through one finally; SIGINT/SIGTERM/SIGHUP await
the same coordinator before exiting with the conventional 128+signum
code; the process exit hook keeps a bounded synchronous best-effort
fallback for abrupt exits. Error reporting and redaction are
preserved, and stderr messages are now redacted while the private root
is still known.

A deterministic interruption test starts the executor in a child
process, pauses it immediately after seed snapshot creation through a
narrowly scoped NODE_ENV=test marker-file hook that is inert in
production, delivers each signal, and asserts the temp seed snapshot
directory is removed, the conventional exit code is set, and no runner
workspace content survives. A normal run in the same harness proves
routine cleanup still passes.
@chubes4
chubes4 merged commit 897faeb into main Jul 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snapshot runner workspace outside artifact topology

1 participant